package actions;

import gui.MainFrame;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;

public class MyCloseActionHandler extends AbstractAction {

    private String tabName;

    public MyCloseActionHandler(String tabName) {
        this.tabName = tabName;
    }

    public String getTabName() {
        return tabName;
    }

    public void actionPerformed(ActionEvent evt) {

        int index = MainFrame.getInstance().getTabbedPane().indexOfTab(getTabName());
        if (index >= 0) {

            MainFrame.getInstance().getTabbedPane().removeTabAt(index);
            JButton btn = (JButton) evt.getSource();
            btn.removeAll();

        }

    }

}   